<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" value="">

    <!-- 
        当按回车键的时候，就自动聚焦到文本框
     -->

     <script>
         const inputObj = document.querySelector("input")
         document.addEventListener("keydown",function(e){
             console.log(e.key)
             if(e.key=='Enter'){
                 console.log("这是回车键")
                 inputObj.focus();
             }
         })
     </script>
    
</body>
</html>